package com.jyw.flowable.controller;

import com.jyw.common.annotation.Log;
import com.jyw.common.core.controller.BaseController;
import com.jyw.common.core.domain.CommonResult;
import com.jyw.common.core.page.TableDataInfo;
import com.jyw.common.enums.BusinessType;
import com.jyw.flowable.domain.dto.WfDeployPageDto;
import com.jyw.flowable.domain.dto.WfPublishPageDto;
import com.jyw.flowable.domain.vo.WfDeployVo;
import com.jyw.flowable.service.IWfDeployService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author Created by ZhangCheng on 2023/11/14 （流程部署）
 */
@RestController
@RequestMapping("/flowable/deploy")
public class WfDeployController extends BaseController {

    @Resource
    private IWfDeployService wfDeployService;

    /**
     * 查询流程部署列表
     */
    @PreAuthorize("@ss.hasPermi('flowable:deploy:list')")
    @GetMapping("/list")
    public TableDataInfo<WfDeployVo> list(WfDeployPageDto wfDeployPageDto) {
        return wfDeployService.list(wfDeployPageDto);
    }

    /**
     * 查询流程部署版本历史
     */
    @PreAuthorize("@ss.hasPermi('flowable:deploy:publishList')")
    @GetMapping("/publishList")
    public TableDataInfo<WfDeployVo> publishList(WfPublishPageDto wfPublishPageDto) {
        return wfDeployService.queryPublishList(wfPublishPageDto);
    }

    /**
     * 删除流程部署
     */
    @PreAuthorize("@ss.hasPermi('flowable:deploy:remove')")
    @Log(title = "流程部署", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable String[] ids) {
        wfDeployService.deleteByIds(ids);
        return CommonResult.success();
    }
}
